package com.micro.common.service.orm.enums;

import com.micro.framework.starter.common.data.enums.StatusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
@AllArgsConstructor
public enum  TaskStatus {
    WAIT("10", "待处理"),
    DONE("20", "已处理"),
    CANCEL("30", "已取消"),
    ;

    private String code;
    private String name;


    public static String getNameByCode(String code) {
        TaskStatus statusEnum = Arrays.stream(TaskStatus.values())
                .filter(m -> m.code.equals(code))
                .findFirst()
                .orElse(null);
        return Objects.nonNull(statusEnum) ? statusEnum.getName() : null;
    }
}
